package com.ruoyi.handing.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.handing.domain.AlgsHandingRecord;
import com.ruoyi.handing.service.IAlgsHandingRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 处理记录Controller
 * 
 * @author ruoyi
 * @date 2023-03-24
 */
@RestController
@RequestMapping("/handingRecord")
public class AlgsHandingRecordController extends BaseController
{
    @Autowired
    private IAlgsHandingRecordService algsHandingRecordService;

    /**
     * 查询处理记录列表
     */
    @RequiresPermissions("handingRecord:handingRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsHandingRecord algsHandingRecord)
    {
        startPage();
        List<AlgsHandingRecord> list = algsHandingRecordService.selectAlgsHandingRecordList(algsHandingRecord);
        return getDataTable(list);
    }

    /**
     * 导出处理记录列表
     */
    @RequiresPermissions("handingRecord:handingRecord:export")
    @Log(title = "处理记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsHandingRecord algsHandingRecord)
    {
        List<AlgsHandingRecord> list = algsHandingRecordService.selectAlgsHandingRecordList(algsHandingRecord);
        ExcelUtil<AlgsHandingRecord> util = new ExcelUtil<AlgsHandingRecord>(AlgsHandingRecord.class);
        util.exportExcel(response, list, "处理记录数据");
    }

    /**
     * 获取处理记录详细信息
     */
    @RequiresPermissions("handingRecord:handingRecord:query")
    @GetMapping(value = "/{algsHandingId}")
    public AjaxResult getInfo(@PathVariable("algsHandingId") Long algsHandingId)
    {
        return success(algsHandingRecordService.selectAlgsHandingRecordByAlgsHandingId(algsHandingId));
    }

    /**
     * 新增处理记录
     */
    @RequiresPermissions("handingRecord:handingRecord:add")
    @Log(title = "处理记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsHandingRecord algsHandingRecord)
    {
        return toAjax(algsHandingRecordService.insertAlgsHandingRecord(algsHandingRecord));
    }

    /**
     * 修改处理记录
     */
    @RequiresPermissions("handingRecord:handingRecord:edit")
    @Log(title = "处理记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsHandingRecord algsHandingRecord)
    {
        return toAjax(algsHandingRecordService.updateAlgsHandingRecord(algsHandingRecord));
    }

    /**
     * 删除处理记录
     */
    @RequiresPermissions("handingRecord:handingRecord:remove")
    @Log(title = "处理记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{algsHandingIds}")
    public AjaxResult remove(@PathVariable Long[] algsHandingIds)
    {
        return toAjax(algsHandingRecordService.deleteAlgsHandingRecordByAlgsHandingIds(algsHandingIds));
    }
}
